﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_1380_LuckyNumbers
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[][] nums = new int[][] 
            {
                new int[]{7,8 },
                new int[]{1,2 },
            };

            foreach (var item in LuckyNumbers(nums))
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
        public static IList<int> LuckyNumbers(int[][] matrix)
        {
            IList<int> list = new List<int>();
            //暴力解法
            for (int i = 0; i < matrix.Length; i++)
            {
                int rowMin = int.MaxValue;
                int x = 0, y = 0;
                for (int j = 0; j < matrix[i].Length; j++)
                {
                    if (matrix[i][j]< rowMin)
                    {
                        rowMin = matrix[i][j];
                        x = i;
                        y = j;
                    }
                }
                bool isMin = true; ;
                for (int k = 0; k < matrix.Length; k++)
                {
                    if (matrix[k][y]> rowMin)
                    {
                        isMin = false;
                        break;
                    }
                }
                if (isMin) list.Add(rowMin);
            }
            return list;
        }
    }
}
